# -*- coding: utf-8 -*-
import json

def getDataSourceList(request):
    request.cursor_standard.execute('''
        select * from data_source_dict
    ''')
    rows = request.cursor_standard.fetchall()
    return json.dumps(rows, ensure_ascii=False)

    
def updateDataSource(request):
    request.cursor_standard.execute(request.formatSql('''
        update data_source_dict 
        set data_source_code = '${data_source_code}' ,
            data_source_name = '${data_source_name}' 
        where data_source_id = ${data_source_id}
    '''))
    effectRow = request.cursor_standard.rowcount
    print("受影响行数：",effectRow)
    return str(effectRow)


def insertDataSource(request):
    request.cursor_standard.execute(request.formatSql('''
        insert into data_source_dict(data_source_code,data_source_name)
        values('${data_source_code}','${data_source_name}')
    '''))
    return str(request.cursor_standard.rowcount)